package com.longma.server.controller;

import com.longma.server.entity.AlarmProcess;
import com.longma.server.pojo.UserResponseEntity;
import com.longma.server.pojo.dto.AlarmProcessAddDTO;
import com.longma.server.service.IAlarmProcessService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import javax.validation.constraints.NotNull;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author HAIBO
 * @since 2021-04-28
 */
@RestController
@Validated
@RequestMapping("/api/alarm-process-list")
public class AlarmProcessController {
    @Autowired
    private IAlarmProcessService alarmProcessService;


    @ApiOperation(value = "新增告警处理单")
    @PostMapping("/add")
    public UserResponseEntity<AlarmProcess> addAlarmProcess(@Valid @RequestBody AlarmProcessAddDTO addRequestDTO){
        return UserResponseEntity.success(alarmProcessService.addAlarmProcess(addRequestDTO));
    }

    @ApiOperation(value = "通过告警处理单id查询")
    @GetMapping("/get")
    public UserResponseEntity<AlarmProcess> getAlarmProcessById(@NotNull(message = "告警处理单id不能为空")  @RequestParam(name = "id") Integer id){
        return UserResponseEntity.success(alarmProcessService.getAlarmProcessById(id));
    }

    @ApiOperation(value = "通过告警记录id查询")
    @GetMapping("/getbyalarmrecordid")
    public UserResponseEntity<AlarmProcess> getAlarmProcessByAlarmRecordId(@NotNull(message = "告警记录id不能为空")  @RequestParam(name = "id")Integer id){
        return UserResponseEntity.success(alarmProcessService.getAlarmProcessByAlarmRecordId(id));
    }
}

